﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Wilson/MP/Base.Master" AutoEventWireup="true" CodeBehind="LinkCreate.aspx.cs" Inherits="WebsiteAdmin.Wilson.LinkInfo.LinkCreate" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="server">新建链接 - 链接</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head_Meta" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Head_Css" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Head_Script" runat="server">
    <script src="../Script/Mootools.Smoothbox.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        var MenuViewID = 6;
	    window.addEvent('domready', function() {
            $('submitbtn').addEvent('click', function() {
                Submit();
            });
        });
		    function Submit() {
            var txtLinkTitle = $('txtLinkTitle').get('value').trim();
            if (txtLinkTitle.length == 0) {
                alert('链接标题错误');
                return false;
            }
            var txtLinkURL = $('txtLinkURL').get('value').trim();
            var txtSortBy = $('txtSortBy').get('value').trim().toInt();
            if (isNaN(txtSortBy)) {
                alert('必须是整数');
                return false;
            }
            Insert(
            txtLinkTitle,
            txtLinkURL,
            txtSortBy);
        }
        
        function Insert(txtLinkTitle,
            txtLinkURL,
            txtSortBy) {

            new Request.JSON({
                method: 'post',
                url: 'Handler/Create.ashx',
                data: {
                    LinkTitle: txtLinkTitle,
                    LinkURL: txtLinkURL,
                    SortBy: txtSortBy
                },
                noCache: true,
                onSuccess: function(data, text) {
                    if (data.Done == 'Success') { 
                        
                        if(confirm('新增成功，返回列表？'))
                        {
                            document.location.href = '/Wilson/LinkInfo/LinkList.aspx';
                        };
                        //LightBox.remove();
                    }
                    else
                    {
                        alert('新增失败');
                        //LightBox.remove();
                    }
                },
                onFailure: function(xhr) {
                    alert(xhr.statusText);
                    //LightBox.remove();
                }
            }).send();
        }
    </script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Body_Top" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Body_Content" runat="server">
    <div class="infobox">
    <h3>
    <span>新建链接</span>
		<a href="/Wilson/LinkInfo/LinkList.aspx" class="back action">返回链接列表</a>
    </h3>
    <div class="mt10">
        <form id="MyForm" action="">
    <table style="width: 800px;">
        <tr>
            <td align="right" width="100">
                <span class="Need">标题：</span></td>
            <td>
                    <input type="text" id="txtLinkTitle" name="txtLinkTitle" style="width:300px;" value="" maxlength="40" />
                    <font color="red">*</font>
            </td>
        </tr>
        <tr>
            <td align="right">
                链接：
            </td>
            <td>
                <input type="text" id="txtLinkURL" style="width:400px;" value="" />
            </td>
        </tr>
        
        <tr id="TRscript">
            <td align="right">
                <span class="Need">排序：</span></td>
            <td>
                <input id="txtSortBy" type="text" style="width:50px;" maxlength="3" value="0" /><font color="red">&nbsp;*<span id="Span1"></span></font></td>
        </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
		<tr>
			<td width="100" height="40">&nbsp;</td>
			<td>
				<input id="submitbtn" type="button" value="提交" class="btn" />
				<input type="reset" value="重置" class="btn" />
			</td>
		</tr>
	</table>
    </form>
    </div>
</div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Body_Foot" runat="server">
</asp:Content>
